<?php if($this->questions):?>
	<table class="ui-widget ui-widget-content" >
		<thead>
			<tr class="ui-widget-header" >
				<th>desc</th>
				<th>#</th>
				<th>#</th>
				<th>#</th>
			</tr>
		</thead>
		<tbody>
		<?php
			$updateUrl = $this->url(array('ctrl' => $this->controllerName, 'act' => 'update'));
			$deleteUrl = $this->url(array('ctrl' => $this->controllerName, 'act' => 'delete'));
			$answersUrl = $this->url(array('ctrl' => 'answers', 'act' => 'lists'));
			foreach ($this->questions as $question):
				?>
				<tr>
					<td><?php echo $this->escape($question->_desc);?></td>
					<td><a class="ajaxUpdateLink"  href="<?php echo $updateUrl.'&id='.$question->id;?>" >Update</a></td>
					<td><a class="ajaxDeleteLink"  href="<?php echo $deleteUrl.'&id='.$question->id;?>" >Delete</a></td>
					<td><a  href="<?php echo $answersUrl.'&qId='.$question->id;?>" >Answers</a></td>
				</tr>
				<?php
			endforeach;?>
		</tbody>
	</table>
	<script type="text/javascript">
		$(function(){
			$('.ajaxDeleteLink').click(function(){
				if(confirm("Are You sure???")){
					var $deleteLink = $(this); 
					$.ajax({
						dataType: 'json',
						url: $deleteLink.attr('href'),
						success: function(dataFromServer){
							if(dataFromServer && dataFromServer.isDeleted){
								$deleteLink.parents('tr').remove();
							}
						}
					});
				}
				return false;
			});
		})
	</script>
<?php else:
	echo 'No Questions for This Test';
endif;?>